package file;

import java.io.File;
import java.io.IOException;

import org.junit.*;
import static org.junit.Assert.*;

public class FileChangerTest {
	
	@Test
	public void wantWordTest() throws IOException{
		assertEquals(FileChanger.wantWord(new File("test.txt"), "まみ"), null);
		assertEquals(FileChanger.wantWord(new File("test.txt"), "ああ"), "ああああ");
		assertEquals(FileChanger.wantWord(new File("test.txt"), "いお"), "ああ　いおあ");
		assertEquals(FileChanger.wantWord(new File("test.txt"), ""), "ああああ");
		assertEquals(FileChanger.wantWord(new File("test.txt"), "おい"), "いおいおい");
	}
	
	@Test
	public void htmlTagSearchTest(){
		String line = "<html><head><title>ああsrcあ</title><body><a href=\"srctest.txt\"><img src=\"gazou.jpg\"></a></body></html>";
		String line2 = "<html><head><title>ああsrcあ</title><body><a href=\"srctest.txt\">src</a></body></html>";
		assertEquals(FileChanger.htmlTagSearch(line, "src"), "<img src=\"gazou.jpg\">");
		assertEquals(FileChanger.htmlTagSearch(line2, "src"), null);
	}
	
	@Test
	public void fileNamesTest(){
		String[] names = FileChanger.fileNames("test");
		assertEquals(names[0],"test\\test1.dat");
		assertEquals(names[1],"test\\test2.dat");
		assertEquals(names[2],"test\\test3.txt");
		assertEquals(names[3],"test\\test4.nul");
	}
}
